<?php
	/**
	*  Manage users with File Explorer
	*/
	if (!defined('EXPONENT')) exit('');
	if (exponent_permissions_check(array('administrate','configure'),$loc)){
		$id = 0;
		$obj = null;
		$page=1;
		$user = null;
		$users = $db->countObjects('filemanagermodule_users');
		
		if (isset($_REQUEST['page']))
			$page=intval($_REQUEST['page']);
			
		$pageSize=10;
		if (isset($_REQUEST['pageSize']))
			$pageSize=intval($_REQUEST['pageSize']);
		
		$start=($page-1)*$pageSize;
		
		$sql="SELECT {$db->prefix}filemanagermodule_users.*,{$db->prefix}user.username FROM {$db->prefix}filemanagermodule_users INNER JOIN {$db->prefix}user ON {$db->prefix}filemanagermodule_users.user_id = {$db->prefix}user.id ORDER BY {$db->prefix}user.username LIMIT {$start},{$pageSize}";
		
		$data=$db->selectObjectsBySql($sql);
		
		$ret_object = null;
		$ret_object->total = count($data);
		$ret_object->rows = $data;
		
		echo json_encode($ret_object);
	}
	die();
?>